package com.nd.sdp.android.young.app.b.implementation.view;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.google.auto.service.AutoService;
import com.nd.sdp.android.young.app.a.api.IStartA;
import com.nd.sdp.android.young.app.b.implementation.R;
import com.nd.sdp.android.young.app.main.api.IPage;
import com.zen.android.monet.wrapper.Monet;

import java.util.ServiceLoader;

import static com.nd.sdp.android.young.utils.Services.load;

@IPage(title = "PageB", iconName = "ic_account_balance_grey_500_36dp")
@AutoService(Fragment.class)
public class BFragment extends Fragment {

    public static BFragment newInstance() {
        return new BFragment();
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_b, container, false);
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        Monet.with(view.getContext())
                .load(R.drawable.ic_account_balance_grey_500_36dp)
                .into(view.findViewById(R.id.iv));
        view.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                load(IStartA.class)
                        .start(v.getContext());
            }
        });
    }
}
